package com.leyantech.ecp.agenx.dispatcher;

import com.leyantech.chaos.kafka.KafkaConsumerStringClient;
import com.leyantech.chaos.kafka.KafkaProducerStringClient;
import com.leyantech.ecp.agenx.common.ClusterVerticle;
import com.leyantech.ecp.agenx.dispatcher.di.DispatcherModule;

import com.google.common.collect.Lists;
import com.google.inject.Inject;
import com.google.inject.Module;
import com.google.inject.name.Named;

import java.util.List;

/**
 * @author eahau, {@literal <eahau@foxmail.com>}
 * @date 2022-10-25.
 */
public class DispatcherVerticle extends ClusterVerticle {

  @Inject
  @Named("input")
  private KafkaConsumerStringClient inputConsumer;

  @Inject
  @Named("output")
  private KafkaConsumerStringClient outputConsumer;

  @Inject
  private KafkaProducerStringClient producer;

  @Override
  protected List<Module> dependentModules() {
    return Lists.newArrayList(new DispatcherModule());
  }

  @Override
  public void start() {
    inputConsumer.start();
    outputConsumer.start();
  }

  @Override
  public void stop() {
    inputConsumer.destroy();
    outputConsumer.destroy();
    producer.destroy();
  }

  public static void main(String[] args) {
    new DispatcherVerticle().startVerticle();
  }

}
